Skip to content

ci(doop): train S7 watchers and /healthz revision (CHE-5550) [squash] - #103

Merged
congvc-dev merged 10 commits into
agent/tofu/che-5548-2644b627ca4afrom
agent/x99-claude-sonnet-200k/che-5550-e83936079091
Nov 20, 2026
Merged

congvc-dev merged 10 commits into
agent/tofu/che-5548-2644b627ca4afrom
agent/x99-claude-sonnet-200k/che-5550-e83936079091

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Train S7 of CHE-5474 (plan rev 5, rule C-7). Stacked on S5 (PR 99). Issue: CHE-5550. Switch state: DOOP_DEPLOY_TRAIN is off (set by Cheese, read back 2026-11-20 with gh variable get). Nothing in this PR sets it. No deploy is approved by this PR.

What changed

  • .github/workflows/cd-freshness-watch.yml (hosted, cron 12,27,42,57 * * * *): 45 min after a D2 slot, with a qualified candidate that is not the last confirmed D2 SHA and no D2 run since the slot, sends one schedule_backup dispatch. At 90 min it prints ::error:: and fails. A failed D1 build is rerun once. Runs as github-actions[bot] (the one actor D2 admits for schedule_backup) with contents: read, actions: write.
  • .github/workflows/cd-live-revision.yml (schedule only, cheese-x99-gate): reads https://$DOOP_C00_HOST/healthz and fails when the live revision is behind the last successful D2 SHA. Read only.
  • scripts/cd-watch.mjs: the decisions are pure functions (lastSlot, freshness, liveVerdict, lastDeployed, deploymentRecord); the CLI reads GitHub and /healthz.
  • /healthz returns { ok, revision }. image.yml passes DOOP_REVISION=${{ github.sha }}; the Dockerfile bakes it into /app/REVISION; server/revision.ts reads it (unknown if absent or not a 40-hex SHA). No env.ts or .env.example change.
  • deploy/cd/README.md and .context/TECHSTACK.md document both watchers.

P1 fix (review of e7e6be6): durable last confirmed SHA

Finding: the watchers searched only 30 D2 runs; after 30 skipped slots the SHA was null, so the live watch passed an unreachable /healthz and the freshness watch treated the deployed candidate as overdue.

  • Durable record. D2's evidence job (permissions: deployments: write, after the artifact upload, so a failed record never loses the artifact) runs node scripts/cd-watch.mjs record deploy-evidence.json on a confirmed deploy: a GitHub deployment in environment c00-doop at the candidate SHA with a success status, read back before the step passes. Watchers read it with deployments: read.
  • Tri-state, never a guess. known / none (proven first deployment) / unknown (history unreadable). unknown alarms at once (freshness) or fails (live). It is never treated as "nothing deployed".
  • Fallback scan of deploy-evidence artifacts is paginated, up to 100 runs. A green run whose evidence is gone, a confirmed artifact with a bad SHA, or hitting the limit is unknown.
  • /healthz must answer ok: true with a 40-hex revision even when none.
  • Tests added: 45 runs with 30+ skips, expired/unreadable evidence, bad SHA, scan limit, malformed record, unhealthy and behind live revision, and workflow assertions for deployments permissions and the record step.

RED (before the fix): bunx vitest run tests/cdWatch.test.ts tests/cdWatchWorkflows.test.ts tests/healthzRevision.test.ts tests/deployWorkflow.test.ts -> 21 failed | 27 passed (the other 27 were the old assertions).
GREEN (after, head e52b315):

 Test Files  4 passed (4)
      Tests  98 passed (98)

Also green: tsgo --noEmit, doc-lint, oxlint (type-aware) and eslint on scripts, prettier. The bun test pregate lane is still red for the unrelated inject reason below.

Judgment calls added: (6) cd-deploy.yml (S5's file) changes in the evidence job only: one permission and one step; the existing evidence-job constraints in tests/deployWorkflow.test.ts still pass. (7) An unreachable /healthz fails even when nothing has deployed. (8) Deployment records are an additive GitHub object; no deploy power is added (deployments: write on a hosted job that has no secrets and no environment).

Second P1 fix (review of e52b315): the record must not hide a newer deploy

Findings: (1) a valid record suppressed all newer evidence, so a confirmed deploy B whose record write failed left both watchers on the older SHA A, and the live watcher could pass a rollback to A. (2) gh api -f sent auto_merge and production_environment as strings.

  • Reconcile. lastDeployed now takes the record as { sha, runId } (the D2 run id is in the deployment description ... (D2 run <id>)). The runs newer than the record's run are read newest first: a confirmed run with another SHA, a confirmed run with no usable SHA, or a newer green run whose evidence is gone gives unknown and fails both watchers visibly; a newer failed run with no evidence is skipped (it failed before it could confirm). The record's run and older runs are not read, so artifact expiry cannot hide a good record. Scan limit (100) before the record's run is unknown. A record without a run id is taken only if the newest confirmed evidence agrees.
  • Typed fields. ghPostArgs sends strings with -f and booleans with -F. recordDeployment (pure, gh and read-back injected) is tested on the actual requests, the read-back mismatch, a refused write (no status is posted), and a non-confirmed run.
  • Docs: deploy/cd/README.md and .context/TECHSTACK.md.

RED (new tests against the old code): bunx vitest run tests/cdWatch.test.ts -> 11 failed | 33 passed (44).
GREEN (head e4e1f5e): bunx vitest run tests/cdWatch.test.ts tests/cdWatchWorkflows.test.ts tests/healthzRevision.test.ts tests/deployWorkflow.test.ts -> 4 passed (4), 111 passed (111). Also green: tsgo --noEmit, oxlint (type-aware), eslint on scripts/cd-watch.mjs, prettier. The bun test lane stays red for the unrelated inject reason below.

Judgment call (9): with a record, every run newer than it is read, including skipped green ones, because only evidence says whether a run deployed. A very long quiet stretch (over 100 D2 runs, about 33 days at three slots a day, with no deploy) makes the live watcher unknown and fails it visibly rather than guess.

Tests of the first delivery (e7e6be6)

Command: bunx vitest run tests/cdWatch.test.ts tests/cdWatchWorkflows.test.ts tests/healthzRevision.test.ts

RED (before any implementation):

 Test Files  3 failed (3)
      Tests  12 failed | 2 passed (14)

(the missing script and server modules failed to import; the workflow and README assertions failed on missing files)

GREEN (after):

 Test Files  3 passed (3)
      Tests  40 passed (40)

Also green: tsgo --noEmit, bun run lint, format:check, ci-policy check, doc-lint, and 5 related test files (100 tests).

Not green, and not caused by this change: the generic bun test pregate lane fails 76 of 90 files with Export named 'inject' not found in module 'bun:test'. The repo's test script is vitest run; an untouched file (tests/guides.test.ts) fails the same way under bun test. My two pure-function files also pass under bun test (35 pass).

Read-back: watchers run before the switch can turn on

  • Both workflows are scheduled and are a clean no-op while DOOP_DEPLOY_TRAIN is not on. They are on the default branch's schedule as soon as this lands.
  • deploy/cd/README.md makes a green scheduled run of each watcher a precondition of turning the switch on (asserted by cdWatchWorkflows.test.ts).
  • Needed before the switch: repo variable DOOP_C00_HOST.

Judgment calls for the reviewer

  1. "Last successful D2 SHA" is the deployment record D2 writes on a confirmed deploy, with the deploy-evidence artifact scan as fallback, because a skipped D2 ends green.
  2. "Ahead" means the candidate SHA differs from that SHA (none counts as behind).
  3. The 90 min alarm fires whether or not a D2 run exists.
  4. liveVerdict with a proven none still needs a healthy /healthz, and passes when live is ahead (a deploy whose evidence is not written yet).
  5. No runtime guard in deploy-gate that the watchers are active; the precondition is documentation plus the test.

Review gates

Cross-lab code signer required (x99-codex-terra); no Anthropic-lab agent may sign.

Round 3 fix (head 8933e0d)

Finding (terra, P1): a confirmed deploy can lose its evidence when the upload fails; lastDeployed skipped such a failed run and could report an older SHA as current.

  • Fix: any run newer than the record whose evidence is missing, green, failed or cancelled, now gives unknown (fails both watchers visibly). Evidence is written on every run, so absence is unproven, not "did not confirm".
  • Tests (tests/cdWatch.test.ts): RED on old code, 3 failed | 43 passed (46): failed run with no evidence, cancelled run with no evidence, and confirm B / upload failed / record A / live A (live watcher). GREEN: 4 S7 files, 113 tests passed.
  • Also green: tsgo --noEmit, oxlint (type-aware), eslint, prettier. Docs updated in deploy/cd/README.md.
  • Trade-off: a failed or cancelled D2 run that never reached its evidence job now makes the history unknown until a newer run writes a record or evidence. This fails visibly rather than guessing.
  • DOOP_DEPLOY_TRAIN stays off. No deploy authority used.

Round 4 fix (head 4e4787d, CHE-8873 review of 8933e0d)

Finding (terra, P1): lastDeployed stopped at the record's run ID, but run ID does not order deployments: an older run can confirm B after a newer run recorded A, and lose its evidence upload; live A then passed.

  • Fix: deploys are ordered by confirmation time. D2's record description now carries confirmed <UTC>; the record step fails when confirmed evidence has no confirmation time. The watchers check every D2 run with last activity (updated_at, moved by a rerun) at or after the record's confirmation: no evidence is unknown; evidence confirming another SHA after the record is unknown; confirmed before it is older and ignored. Runs created over 30 days before the record end the scan. Unfinished runs list too: pending under 3 h (freshness idles, live not judged that tick), unknown when stuck. With no record the latest confirmation wins.
  • Tests: RED on the 8933e0d script, 10 failed (the older-run regression, live A check, pending, record time); GREEN: 5 files, 136 tests passed (bunx vitest run tests/cdWatch.test.ts tests/cdWatchWorkflows.test.ts tests/healthzRevision.test.ts tests/deployEvidence.test.ts tests/deployWorkflow.test.ts). bun run lint (oxlint + eslint) and prettier clean.
  • Live retest: NOT-SHOWN. DOOP_DEPLOY_TRAIN stays off; no deploy authority used.
  • Trade-off: pending defers only the SHA comparison (see round 5).

Round 5 fix (head 8cd8a6d, CHE-8873 review of 4e4787d)

Finding (terra, P1): a pending D2 run made freshness idle before the 90 min deadline, and the live watcher passed without reading /healthz.

  • Fix: pending defers only the SHA comparison. Freshness still alarms once the slot is 90 min old; live still needs ok: true and a 40-hex revision from /healthz and fails otherwise.
  • Tests: RED on the 4e4787d script, 2 failed (alarm at 100 min with a pending run; unreachable, unhealthy or malformed /healthz while pending). GREEN: 5 files, 138 tests passed (same command as round 4). oxlint, eslint, prettier clean.
  • Live retest NOT-SHOWN. DOOP_DEPLOY_TRAIN stays off.

congvc-bot[bot] added 7 commits November 20, 2026 14:25
…ce (CHE-5549)

Rules C-9 and C-12 of CHE-5474. Ships with DOOP_DEPLOY_TRAIN absent or off.
…lock (CHE-5549)

Review round 1 on the S5 slice:
- deploy-gate recheck runs the real quiescence proof (c00.sh quiescence) instead of a hardcoded ok.
- c00.sh confirm and rollback prove migration quiescence under the lock, switch on or off.
- The confirm and rollback checks run inside c00.sh after take_lock, so a newer deployment or a changed marker that
  lands while waiting for the lock is seen (superseded, none, refused); the workflow no longer decides before the lock.
- The rollback job is one c00.sh step; the marker token and suspension follow the step's own go output.
… (CHE-5549)

Quiescence in confirm reads the live database, so the job needs the same
C00_COMPOSE_DIR and C00_PG_CONTAINER as deploy and rollback. Test drives
c00.sh with only each job's own env block.
…CHE-5550)

The watchers searched only the 30 newest D2 runs for a confirmed deployment.
After 30 skipped slots the SHA came back null: the live watch then passed an
unreachable /healthz and the freshness watch treated the deployed candidate as
overdue.

- D2's evidence job records each confirmed deploy as a GitHub deployment
  (environment c00-doop, deployments: write), read back before the step passes.
- The last successful D2 SHA is tri-state: known, none (a proven first
  deployment) or unknown. Unknown history alarms and fails visibly.
- Artifact scan is only the fallback: paginated, up to 100 runs, and a green
  run whose evidence is gone counts as unknown.
- /healthz must be healthy with a 40-hex revision even when nothing deployed.
…typed booleans (CHE-5550)

A prior deployment record no longer hides a newer confirmed deploy whose own
record write failed: that history is unknown and fails both watchers visibly.
The record carries its D2 run id; auto_merge and production_environment go
out as JSON booleans (gh api -F) and the request and failure path are tested.
Base automatically changed from agent/x99-claude-sonnet-200k/che-5549-105c4406f6a8 to agent/tofu/che-5548-2644b627ca4a November 20, 2026 18:13
congvc-bot[bot] added 3 commits November 21, 2026 01:24
… run ID (CHE-8873, CHE-5550)

Round 4 P1: an older run can confirm after a newer run recorded another SHA. Check every run
active at or after the record's confirmation, treat unfinished runs as pending/stuck, record the
confirmation time in the deployment description.
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 20, 2026 22:13
@congvc-bot-x99
congvc-bot-x99 Bot requested a review from congvc-dev November 20, 2026 22:15
@congvc-dev
congvc-dev merged commit b48fa9d into agent/tofu/che-5548-2644b627ca4a Nov 20, 2026
12 checks passed
@congvc-dev
congvc-dev deleted the agent/x99-claude-sonnet-200k/che-5550-e83936079091 branch November 20, 2026 22:19
congvc-dev pushed a commit that referenced this pull request Nov 23, 2026
…smoke (CHE-5548) [squash] (#56)

* ci(doop): train S4c compat sandbox, isolation probes, env allowlist, sweep, smoke (CHE-5548)

* fix(deploy): real smoke ops, supervised clone migration, probe the sandbox gateway (CHE-5548)

* fix(deploy): bounded quiescence proof and durable needs_operator guard (CHE-5548)

- proveQuiescence: kill, wait, record (pid, backend_start), terminate, prove three
  facts inside one 30 s budget; every step bounded; a timeout leaves a fact unproven.
- Failed migration: clone ledger must equal the pre-migration ledger.
- needs_operator writes a guard file that no sweep removes, keeps the sandbox, skips
  the final sweep. runCompat, c00.sh apply, rollback, sweep and guard refuse until
  the facts hold; lift calls c00.sh guard.
- Tests: stuck docker kill/wait/inspect/psql, later job after a failed proof,
  c00.sh refusal. Run against the previous implementation: 67 of 107 failed.
  Written after the code, so retrospective test-first.

* fix(deploy): persist the needs_operator guard before the clone migration, clear it only after proof (CHE-5548)

Red (6 failures) before the change, green (174 passed across compat and c00 suites) after.

* ci(doop): widen drawingBrowser waits to 30s for loaded runners (CHE-6913)

* test(doop): wait for the element probe before navigating away in pageCanvasBrowser (CHE-6913)

* test(doop): raise the expect.poll default to 30s for loaded runners (CHE-6913)

* test(doop): name the stalled drawingBrowser beforeEach step (CHE-6913)

* test(doop): reload the drawing fixture when Chrome aborts its module imports (CHE-7020)

Chrome aborts in-flight requests with net::ERR_NETWORK_CHANGED when host
network interfaces change. The module script in drawing.html then never sets
window.drawingHarness and no wait recovers. Print pageerror/requestfailed/
readyState on a stall and load the page again (3 tries, 8s ready wait).

* test(doop): give elementPanelBrowser waits 12 s on loaded runners (CHE-7021)

The first seedPanel wait timed out at the 5 s puppeteer default on CI shard 2
(run 44129413615, job 134202011472). Widen the file default and the one
explicit 5 s poll to 12 s, under the 15 s per-test limit.

* ci(doop): smoke routes for agents, custom-providers, image-descriptions, icons, photos (CHE-6841)

* ci(doop): smoke write chains for agents and image descriptions, providers contract (CHE-7697)

* ci(doop): train S5 — readback delay, confirm, rollback, evidence (CHE-5549) [squash] (#99)

* ci(doop): train S5 readback delay, confirm, rollback readback, evidence (CHE-5549)

Rules C-9 and C-12 of CHE-5474. Ships with DOOP_DEPLOY_TRAIN absent or off.

* ci(doop): prove quiescence and decide confirm and rollback under the lock (CHE-5549)

Review round 1 on the S5 slice:
- deploy-gate recheck runs the real quiescence proof (c00.sh quiescence) instead of a hardcoded ok.
- c00.sh confirm and rollback prove migration quiescence under the lock, switch on or off.
- The confirm and rollback checks run inside c00.sh after take_lock, so a newer deployment or a changed marker that
  lands while waiting for the lock is seen (superseded, none, refused); the workflow no longer decides before the lock.
- The rollback job is one c00.sh step; the marker token and suspension follow the step's own go output.

* fix(cd): give readback-confirm the compose dir and Postgres container (CHE-5549)

Quiescence in confirm reads the live database, so the job needs the same
C00_COMPOSE_DIR and C00_PG_CONTAINER as deploy and rollback. Test drives
c00.sh with only each job's own env block.

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>

* ci(doop): train S7 watchers and /healthz revision (CHE-5550) [squash] (#103)

* ci(doop): train S5 readback delay, confirm, rollback readback, evidence (CHE-5549)

Rules C-9 and C-12 of CHE-5474. Ships with DOOP_DEPLOY_TRAIN absent or off.

* ci(doop): prove quiescence and decide confirm and rollback under the lock (CHE-5549)

Review round 1 on the S5 slice:
- deploy-gate recheck runs the real quiescence proof (c00.sh quiescence) instead of a hardcoded ok.
- c00.sh confirm and rollback prove migration quiescence under the lock, switch on or off.
- The confirm and rollback checks run inside c00.sh after take_lock, so a newer deployment or a changed marker that
  lands while waiting for the lock is seen (superseded, none, refused); the workflow no longer decides before the lock.
- The rollback job is one c00.sh step; the marker token and suspension follow the step's own go output.

* fix(cd): give readback-confirm the compose dir and Postgres container (CHE-5549)

Quiescence in confirm reads the live database, so the job needs the same
C00_COMPOSE_DIR and C00_PG_CONTAINER as deploy and rollback. Test drives
c00.sh with only each job's own env block.

* ci(doop): train S7 watchers and /healthz revision (CHE-5550)

* fix(ci): keep the last confirmed deploy durably for the D2 watchers (CHE-5550)

The watchers searched only the 30 newest D2 runs for a confirmed deployment.
After 30 skipped slots the SHA came back null: the live watch then passed an
unreachable /healthz and the freshness watch treated the deployed candidate as
overdue.

- D2's evidence job records each confirmed deploy as a GitHub deployment
  (environment c00-doop, deployments: write), read back before the step passes.
- The last successful D2 SHA is tri-state: known, none (a proven first
  deployment) or unknown. Unknown history alarms and fails visibly.
- Artifact scan is only the fallback: paginated, up to 100 runs, and a green
  run whose evidence is gone counts as unknown.
- /healthz must be healthy with a 40-hex revision even when nothing deployed.

* fix(ci): reconcile the deploy record with newer D2 evidence and send typed booleans (CHE-5550)

A prior deployment record no longer hides a newer confirmed deploy whose own
record write failed: that history is unknown and fails both watchers visibly.
The record carries its D2 run id; auto_merge and production_environment go
out as JSON booleans (gh api -F) and the request and failure path are tested.

* fix(ci): treat a newer D2 run with no evidence as unknown, not skipped (CHE-5550)

* fix(ci): order the last confirmed D2 deploy by confirmation time, not run ID (CHE-8873, CHE-5550)

Round 4 P1: an older run can confirm after a newer run recorded another SHA. Check every run
active at or after the record's confirmation, treat unfinished runs as pending/stuck, record the
confirmation time in the deployment description.

* fix(ci): a pending D2 run no longer hides the 90 min alarm or a failed /healthz (CHE-8873, CHE-5550)

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>

* ci(doop): train S3b — audited lift workflow (CHE-5551) [squash] (#104)

* ci(doop): train S3b — audited lift workflow (CHE-5551)

Add cd-lift.yml, the only way from armed/suspended back to clear (plan CHE-5474
C-10.6, C-10.7). Dispatch only, one input (decision_id), allowlisted dispatcher,
C00 runner under the host deploy lock.

scripts/deploy-lift.mjs refuses unless the Multica decision is an approved
doop.deploy_lift by the configured approver, not withdrawn/revoked/expired, its
marker_value equals the standing marker and repo matches, quiescence and
/healthz are proven, and the decision and marker still hold when re-read right
before the write. It then writes clear:<nonce>:<run id>, reads it back and
records lift-evidence.json. A refusal leaves the marker unchanged.

c00.sh gains a `lift` command (guard, lock, quiescence, digest, revision label,
container health). deploy-marker.mjs gains lift() and exports readMarker().
The train switch DOOP_DEPLOY_TRAIN is not touched.

* fix(ci): lift refuses a decision answer that omits withdrawn_at, revoked_at or expires_at (CHE-5551)

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>
Co-authored-by: congvc-bot-x99[bot] <282619718+congvc-bot-x99[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant